<?php
require '../$header.php';

$Email = $DB->escape($_POST['Email']);
$Password = $DB->escape($_POST['Password']);

$Password = md5($Password);

$return = array();

$DB->query("
	SELECT ID, Email 
	FROM user
	WHERE Email = '{$Email}'
	AND Password = '{$Password}'
	LIMIT 1
");

if($DB->num() != 0)
{
	$fetch = $DB->fetch();
	$_SESSION['UserID'] = $fetch['ID'];
	$return['Email'] = $fetch['Email'];
}
else
{
	$return['Error'] = "Invalid Credentials";
}

echo json_encode($return);

require '../$footer.php';
?>